package com.zcmyth;

import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

/**
 * @author Chun Zhang
 */
public class TwoSigmaCodeTestJumbleSort {

  private static class TwoSigmaComparator implements Comparator<String> {
    // All integers should less than strings
    @Override
    public int compare(String o1, String o2) {
      Integer i1 = tryToParseInteger(o1);
      Integer i2 = tryToParseInteger(o2);

      if (i1 == null) {
        if (i2 == null) {
          return o1.compareTo(o2);
        } else {
          return 1;
        }
      } else {
        if (i2 == null) {
          return -1;
        } else {
          return i1 - i2;
        }
      }
    }

    private Integer tryToParseInteger(String input) {
      try {
        return Integer.parseInt(input);
      } catch (NumberFormatException e) {
        return null;
      }
    }
  }

  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    if (scanner.hasNextLine()) {
      System.out.println(sort(scanner.nextLine()));
    } else {
      assert (false);
    }
  }

  public static String sort(String line) {
    String[] array = line.split(" ");
    sort(array);
    return join(array);
  }

  private static void sort(String[] original) {
    TwoSigmaComparator comparator = new TwoSigmaComparator();
    String[] newStrings = Arrays.copyOf(original, original.length);
    Arrays.sort(newStrings, comparator);
    int index = Arrays.binarySearch(newStrings, "a", comparator);
    int c = index < 0 ? -(index + 1) : index;
    int n = 0;
    for (int i = 0; i < original.length; i++) {
      if (original[i].compareTo("a") >= 0) {
        original[i] = newStrings[c++];
      } else {
        original[i] = newStrings[n++];
      }
    }
  }

  private static String join(String[] array) {
    StringBuilder sb = new StringBuilder();
    if (array.length > 0) {
      sb.append(array[0]);
      int index = 1;
      while (index < array.length) {
        sb.append(' ');
        sb.append(array[index++]);
      }
    }
    return sb.toString();
  }
}
